package base.sqlite.demo.user.controller;

import base.sqlite.demo.user.entity.UserEntity;
import base.sqlite.demo.user.service.UserService;
import base.sqlite.demo.util.Res;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "用户信息处理")
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation("测试")
    @GetMapping("/test")
    public Res test(){
        List<UserEntity> list = userService.list();
        return new Res<>(list);
    }

    @ApiOperation("保存")
    @PostMapping("/save")
    public Res save(@RequestBody UserEntity userEntity){
        userService.save(userEntity);
        return new Res<>();
    }

}

